package Sort_Code;

public class Choice_sort {
    //选择排序
    //每个元素和后面的逐个元素进行比较，把大/小的放后面
    public static void main(String[] args) {
        int[] arr={10,9,4,8,6,2,3,1,7,5};
        for (int i = 0; i < arr.length-1; i++) {
            for(int j=i+1;j<arr.length;j++){
                if(arr[i]>arr[j]){
                    int t=arr[j];
                    arr[j]=arr[i];
                    arr[i]=t;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
}
